<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>04</title>
</head>
<body>
    <div id="root">
        <div>用户状态：{{loginStatus ? '在线' : '未登录'}}</div>
    </div>
</body>
<!-- 开发环境版本，包含了有帮助的命令行警告 -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
    var vm = new Vue({
        el: '#root',
        data: {
            r: false,
            loginStatus: false,
        },
        watch: {
            r: function(n, o) {
                if (n) {
                    this.loginStatus = true;
                }
            },
        },
    });
</script>
<style>
</style>
</html>